Write a function in c that includes the following sequence of statements [Wont Compile]

Posted by Cody on Stack Overflow See other posts from Stack Overflow or by Cody
Published on 2010-03-16T00:17:07Z Indexed on 2010/03/16 0:19 UTC
Read the original article Hit count: 251

Filed under:
|
|
|
|

There is a question in my programming languages textbook that is as follows:

Write a C function that includes the following sequence of statements:

x = 21; int x; x = 42;

Run the program and explain the results. Rewrite the same code in C++ and Java and compare the results.

I have written code, and played with it in all three languages but I can not even get it to compile. This includes declaring x above the three lines as well as in the calling function (as this question is obviously attempting to illustrate scoping issues)

I'd like to explain the results and do the comparisons on my own, as it is an assignment question but I was wondering if anyone had any insight as to how to get this code to compile?

Thanks

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++